home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / Pascal OS8 / Everything / ModelessButtons.p < prev    next >
Encoding:
Text File  |  1998-10-30  |  5.7 KB  |  229 lines  |  [TEXT/CWIE]

  1. { ModelessButtons.p -- modeless dialog }
  2. { Created 10/30/98 1:06 PM by AppMaker }
  3.  
  4. Unit ModelessButtons;
  5. Interface
  6.  
  7. Uses
  8.     Types,
  9.     Quickdraw,
  10.     Controls,
  11.     Dialogs,
  12.     Events,
  13.     Lists,
  14.     Menus,
  15.     TextEdit,
  16.     AMDialog;
  17.  
  18. Procedure ShowModelessButtons;
  19.  
  20. type
  21.     CModelessButtons        = object (AMDialog)
  22.  
  23.     {data members}
  24.         mInvisibleHandle:        ControlHandle;
  25.         mStandardHandle:        ControlHandle;
  26.         mDefaultHandle:        ControlHandle;
  27.         mBevelHandle:        ControlHandle;
  28.         mButtonHandle:        ControlHandle;
  29.         mNextHandle:        ControlHandle;
  30.         mNext2Handle:        ControlHandle;
  31.         mGraphicHandle:        ControlHandle;
  32.         mRightHandle:        ControlHandle;
  33.         mLightHandle:        ControlHandle;
  34.         mRight2Handle:        ControlHandle;
  35.         mButton2Handle:        ControlHandle;
  36.         mRight3Handle:        ControlHandle;
  37.         mRect3DHandle:        ControlHandle;
  38.         mLeftIconHandle:        ControlHandle;
  39.         mRightIconHandle:        ControlHandle;
  40.         mTitledPICTHandle:        ControlHandle;
  41.  
  42.     {methods - public}
  43.         Procedure ConnectToData    (inData:    AMSignaler); Override;
  44.  
  45.     {methods - internal}
  46.         Procedure FinishMake; Override;
  47.         Procedure DoItem    (inItemHit:    SInt16); Override;
  48.         Procedure DataChanged    (inDataID:    longint); Override;
  49.  
  50.     end;
  51.  
  52. var
  53.     sModelessButtonsPtr:        DialogPtr;
  54.  
  55. {----------}
  56. Implementation
  57.  
  58. Uses
  59.     ResourceDefs,
  60.     ControlUtils,
  61.     Miscellany;
  62.  
  63. const
  64.     kCapInvisibleLabel        = 1;
  65.     kInvisibleButton        = 2;
  66.     kStandardButton        = 3;
  67.     kDefaultButton        = 4;
  68.     kBevelBox        = 5;
  69.     kButtonButton        = 6;
  70.     kNextButton        = 7;
  71.     kNext2Button        = 8;
  72.     kGraphicBox        = 9;
  73.     kCapcicnLabel        = 10;
  74.     kRightButton        = 11;
  75.     kCapicl8Label        = 12;
  76.     kLightButton        = 13;
  77.     kCapICNLabel        = 14;
  78.     kRight2Button        = 15;
  79.     kCapicl9Label        = 16;
  80.     kButton2Button        = 17;
  81.     kRight3Button        = 18;
  82.     kCapPICTLabel        = 19;
  83.     kRect3DButton        = 20;
  84.     kLeftIconButton        = 21;
  85.     kRightIconButton        = 22;
  86.     kTitledPICTButton        = 23;
  87.  
  88.  
  89. {----------}
  90. Function NewModelessButtons: CModelessButtons;
  91. var
  92.     dialog:        CModelessButtons;
  93. begin
  94.     dialog := nil;
  95.     New (dialog);
  96.  
  97.     if dialog <> nil then begin
  98.         dialog.Initialize;
  99.     end;
  100.     NewModelessButtons := dialog;
  101. end;
  102.  
  103. {----------}
  104. Procedure CreateModelessButtons;
  105. var
  106.     dialog:        CModelessButtons;
  107. begin
  108.     dialog := NewModelessButtons;
  109.  
  110.     dialog.MakeDialog (DLOG_ModelessButtons);
  111. end; {CreateModelessButtons}
  112.  
  113. {----------}
  114. Procedure ShowModelessButtons;
  115. begin
  116.     if sModelessButtonsPtr = nil then begin
  117.         CreateModelessButtons;
  118.     end;
  119.     if sModelessButtonsPtr <> nil then begin
  120.         SelectWindow (sModelessButtonsPtr);
  121.         ShowWindow (sModelessButtonsPtr);
  122.     end;
  123. end; {ShowModelessButtons}
  124.  
  125. {----------}
  126. Procedure CModelessButtons.FinishMake;
  127. var
  128.     errCode:        OSErr;
  129. begin
  130.     sModelessButtonsPtr := mDialog;
  131.  
  132.     mInvisibleHandle := GetControlItem (kInvisibleButton);
  133.     mStandardHandle := GetControlItem (kStandardButton);
  134.     mDefaultHandle := GetControlItem (kDefaultButton);
  135.     SetDefaultState (mDefaultHandle, true);
  136.     errCode := SetDialogDefaultItem (mDialog, kDefaultButton);
  137.     mBevelHandle := GetControlItem (kBevelBox);
  138.     mButtonHandle := GetControlItem (kButtonButton);
  139.     errCode := SetBevelButtonGraphicAlignment (mButtonHandle, kControlBevelButtonAlignCenter, 0, 0);
  140.     mNextHandle := GetControlItem (kNextButton);
  141.     errCode := SetBevelButtonTextPlacement (mNextHandle, kControlBevelButtonPlaceToRightOfGraphic);
  142.     errCode := SetBevelButtonTextAlignment (mNextHandle, kControlBevelButtonAlignTextFlushLeft, 0);
  143.     errCode := SetBevelButtonGraphicAlignment (mNextHandle, kControlBevelButtonAlignLeft, 0, 0);
  144.     mNext2Handle := GetControlItem (kNext2Button);
  145.     errCode := SetBevelButtonTextPlacement (mNext2Handle, kControlBevelButtonPlaceBelowGraphic);
  146.     errCode := SetBevelButtonTextAlignment (mNext2Handle, kControlBevelButtonAlignTextCenter, 0);
  147.     errCode := SetBevelButtonGraphicAlignment (mNext2Handle, kControlBevelButtonAlignTop, 0, 0);
  148.     mGraphicHandle := GetControlItem (kGraphicBox);
  149.     mRightHandle := GetControlItem (kRightButton);
  150.     mLightHandle := GetControlItem (kLightButton);
  151.     mRight2Handle := GetControlItem (kRight2Button);
  152.     mButton2Handle := GetControlItem (kButton2Button);
  153.     mRight3Handle := GetControlItem (kRight3Button);
  154.     mRect3DHandle := GetControlItem (kRect3DButton);
  155.     mLeftIconHandle := GetControlItem (kLeftIconButton);
  156.     mRightIconHandle := GetControlItem (kRightIconButton);
  157.     mTitledPICTHandle := GetControlItem (kTitledPICTButton);
  158. end;
  159.  
  160. {----------}
  161. Procedure CModelessButtons.ConnectToData (
  162.     inData:        AMSignaler); Override;
  163. begin
  164.     inherited ConnectToData (inData);
  165.  
  166. end;
  167.  
  168. {----------}
  169. Procedure CModelessButtons.DoItem (
  170.     inItemHit:        SInt16);
  171. begin
  172.     case inItemHit of
  173.     kInvisibleButton:
  174.             ;{? this button doesn't have a command }
  175.             { DoInvisibleButton; }
  176.     kStandardButton:
  177.             ;{? this button doesn't have a command }
  178.             { DoStandardButton; }
  179.     kDefaultButton:
  180.             ;{? this button doesn't have a command }
  181.             { DoDefaultButton; }
  182.     kButtonButton:
  183.             ;{? this button doesn't have a command }
  184.             { DoButtonButton; }
  185.     kNextButton:
  186.             ;{? this button doesn't have a command }
  187.             { DoNextButton; }
  188.     kNext2Button:
  189.             ;{? this button doesn't have a command }
  190.             { DoNext2Button; }
  191.     kRightButton:
  192.             ;{? this button doesn't have a command }
  193.             { DoRightButton; }
  194.     kLightButton:
  195.             ;{? this button doesn't have a command }
  196.             { DoLightButton; }
  197.     kRight2Button:
  198.             ;{? this button doesn't have a command }
  199.             { DoRight2Button; }
  200.     kButton2Button:
  201.             ;{? this button doesn't have a command }
  202.             { DoButton2Button; }
  203.     kRight3Button:
  204.             ;{? this button doesn't have a command }
  205.             { DoRight3Button; }
  206.     kRect3DButton:
  207.             ;{? this button doesn't have a command }
  208.             { DoRect3DButton; }
  209.     kLeftIconButton:
  210.             ;{? this button doesn't have a command }
  211.             { DoLeftIconButton; }
  212.     kRightIconButton:
  213.             ;{? this button doesn't have a command }
  214.             { DoRightIconButton; }
  215.     kTitledPICTButton:
  216.             ;{? this button doesn't have a command }
  217.             { DoTitledPICTButton; }
  218.  
  219.     end; {switch}
  220. end;
  221.  
  222. {----------}
  223. Procedure CModelessButtons.DataChanged (
  224.     inDataID:        longint); Override;
  225. begin
  226. end;
  227.  
  228. End.
  229.